#include <stdio.h>

int main()
{
    FILE *pf = fopen("xx.txt","w+");
    if(NULL == pf)
        exit(-1);

//    fputs("aaaaaaaaaaaaaaaaaaaaaaaa\n", pf);
//    fputs("bbbbbbbbbbbbbbbbbbbbbbbb\n", pf);
//    fputs("cccccccccccccccccccccccc\n", pf);
//    fputs("dddddddddddddddddddddddd",   pf);

    fputs("aaaaaaaaaaaaaaaaaaaaaaaa\n", pf);
    fputs("bbbbbbbbbbbbbbbbbbbbbbbb\n", pf);
    fputs("cccccccccccccccccccccccc\n", pf);
    fputs("dddddddddddddddddddddddd\n", pf);

    rewind(pf);
    char buf[1024];
//    while(fgets(buf,1024,pf) && !feof(pf))
//    {
//        printf("%s", buf);
//    }

    while(fgets(buf,1024,pf) != NULL)
    {
        printf("%s", buf);
    }
    fclose(pf);

    return 0;
}
